package org.giovanolli.mumi.entities.filter;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * The Class EntityFilter.
 * 
 * @param <T>
 *            the generic type
 */
public abstract class EntityFilter<T> implements Serializable {

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1096996033538138632L;

	/** The sort criterias. */
	private List<SortCriteria> sortCriterias = new ArrayList<SortCriteria>();

	/** The fetch list. */
	private List<String> fetchList;

	/** The not id. */
	private Integer notId;

	/** The exact matches. */
	private boolean exactMatches = false;

	/**
	 * Adds the sort.
	 * 
	 * @param sort
	 *            the sort
	 * @return the entity filter
	 */
	public EntityFilter<T> addSort(final SortCriteria sort) {
		this.sortCriterias.add(sort);
		return this;
	}

	/**
	 * Dd fetch.
	 * 
	 * @param fetch
	 *            the fetch
	 * @return the entity filter
	 */
	public EntityFilter<T> ddFetch(String fetch) {
		this.fetchList.add(fetch);
		return this;
	}

	/**
	 * Gets the fetch list.
	 * 
	 * @return the fetch list
	 */
	public List<String> getFetchList() {
		return Collections.unmodifiableList(fetchList);
	}

	/**
	 * Gets the not id.
	 * 
	 * @return the not id
	 */
	public Integer getNotId() {
		return notId;
	}

	/**
	 * Gets the sort criterias.
	 * 
	 * @return the sort criterias
	 */
	public List<SortCriteria> getSortCriterias() {
		return Collections.unmodifiableList(sortCriterias);
	}

	/**
	 * Checks if is exact matches.
	 * 
	 * @return true, if is exact matches
	 */
	public boolean isExactMatches() {
		return exactMatches;
	}

	/**
	 * Sets the exact matches.
	 * 
	 * @param exactMatches
	 *            the new exact matches
	 */
	public void setExactMatches(boolean exactMatches) {
		this.exactMatches = exactMatches;
	}

	/**
	 * Sets the not id.
	 * 
	 * @param notId
	 *            the new not id
	 */
	public void setNotId(Integer notId) {
		this.notId = notId;
	}

	/**
	 * Sets the sort criterias.
	 * 
	 * @param sortCriterias
	 *            the new sort criterias
	 */
	public void setSortCriterias(List<SortCriteria> sortCriterias) {
		this.sortCriterias = sortCriterias;
	}
}
